<template>
	<section>
		<!--工具条-->
		<el-col :span="24" class="toolbar" style="padding-bottom: 0px;">
			<el-form :inline="true" :model="filters">
				<el-form-item>
					<el-input v-model="filters.name" placeholder="用户名"></el-input>
				</el-form-item>
				<el-form-item>
					<el-button type="primary" v-on:click="getListData">查询</el-button>
				</el-form-item>
			</el-form>
		</el-col>

		<!--列表-->
		<el-table :data="listData" highlight-current-row v-loading="listLoading" @selection-change="selsChange" style="width: 100%;">
			<el-table-column type="selection">
			</el-table-column>
			<el-table-column type="index" fixed>
			</el-table-column>
			<el-table-column prop="executionTime" label="操作所需时间" fixed sortable>
			</el-table-column>
			<el-table-column prop="ip" label="操作者ip" sortable>
			</el-table-column>
			<el-table-column prop="method" label="所使用方法" sortable>
			</el-table-column>
			<el-table-column prop="url" label="url" sortable>
			</el-table-column>
			<el-table-column prop="username" label="用户名称"  sortable>
			</el-table-column>
			<el-table-column prop="visitTime" label="操作时间"  sortable>
			</el-table-column>
		</el-table>

		<!--工具条-->
		<el-col :span="24" class="toolbar">
			<el-pagination layout="prev, pager, next" @current-change="showCurrentChange" :page-size="pageSize" :total="total" style="float:right;">
			</el-pagination>
		</el-col>
	</section>
</template>

<script>
    import util from '../../../common/js/util'
    //import NProgress from 'nprogress'
    //import { getUserListPage, removeUser, batchRemoveUser, editUser, addUser } from '../../api/api';

    export default {
        data() {
            return {
                filters: {
                    name: ''
                },
                listData: [],
                total: 0,
                keyword:'',
                pageSize: 10,
                currentPage:1,
                listLoading: false,
            }
        },
        methods: {
            //获取用户列表
            getListData() {
                let para = {
                    currentPage: this.currentPage,
                    pageSize:this.pageSize,
                    keyword: this.filters.name
                };
                this.listLoading = true;
                this.$http.post('/syslog/findByPage',para).then(res=>{
                    let ajaxResult =  res.data
                    if (ajaxResult.success){
                        this.listData = ajaxResult.data.result;
                        this.total = ajaxResult.data.total
                    }else {
                        this.$message({
                            message: '加载失败',
                            type: 'error'
                        });
                    }
                    this.listLoading = false;
                }).catch(error=>{
                    this.listLoading = false;
                    this.$message({
                        message: '加载失败',
                        type: 'error'
                    });
                })
            },

            //显示当前的页数
            showCurrentChange(val) {
                this.currentPage=val;
                this.getListData();
            },



        },
        mounted() {
            this.getListData();
        }
    }

</script>

<style scoped>

</style>